package net.zoneland.zrdp.biz.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.zoneland.zrdp.common.annotation.Log;
import net.zoneland.zrdp.common.core.controller.BaseController;
import net.zoneland.zrdp.common.core.domain.AjaxResult;
import net.zoneland.zrdp.common.enums.BusinessType;
import net.zoneland.zrdp.biz.domain.FlowMainInfo;
import net.zoneland.zrdp.biz.service.IFlowMainInfoService;
import net.zoneland.zrdp.common.utils.poi.ExcelProcessor;
import net.zoneland.zrdp.common.core.page.TableDataInfo;

/**
 * 流程工单记录Controller
 *
 * @author zonevue
 */
@RestController
@RequestMapping("/biz/flowMainInfo")
public class FlowMainInfoController extends BaseController {

    @Resource
    private IFlowMainInfoService flowMainInfoService;

    /**
     * 查询流程工单记录列表
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(final FlowMainInfo flowMainInfo) {
        startPage();
        final List<FlowMainInfo> list = flowMainInfoService.selectFlowMainInfoList(flowMainInfo);
        return getDataTable(list);
    }

    /**
     * 导出流程工单记录列表
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:export')")
    @Log(title = "流程工单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(final HttpServletResponse response, final FlowMainInfo flowMainInfo) {
        final List<FlowMainInfo> list = flowMainInfoService.selectFlowMainInfoList(flowMainInfo);
        final ExcelProcessor<FlowMainInfo> util = new ExcelProcessor<>(FlowMainInfo.class);
        util.exportExcel(response, list, "流程工单记录数据");
    }

    /**
     * 获取流程工单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") final Long id) {
        return success(flowMainInfoService.selectFlowMainInfoById(id));
    }

    /**
     * 新增流程工单记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:add')")
    @Log(title = "流程工单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody final FlowMainInfo flowMainInfo) {
        return toAjax(flowMainInfoService.insertFlowMainInfo(flowMainInfo));
    }

    /**
     * 修改流程工单记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:edit')")
    @Log(title = "流程工单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody final FlowMainInfo flowMainInfo) {
        return toAjax(flowMainInfoService.updateFlowMainInfo(flowMainInfo));
    }

    /**
     * 删除流程工单记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowMainInfo:remove')")
    @Log(title = "流程工单记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable final Long[] ids) {
        return toAjax(flowMainInfoService.deleteFlowMainInfoByIds(ids));
    }
}
